(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

a__f(b, X, c) → a__f(X, a__c, X)
a__cb
mark(f(X1, X2, X3)) → a__f(X1, mark(X2), X3)
mark(c) → a__c
mark(b) → b
a__f(X1, X2, X3) → f(X1, X2, X3)
a__cc

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

a__f(b, X, c) → a__f(X, a__c, X) [1]
a__cb [1]
mark(f(X1, X2, X3)) → a__f(X1, mark(X2), X3) [1]
mark(c) → a__c [1]
mark(b) → b [1]
a__f(X1, X2, X3) → f(X1, X2, X3) [1]
a__cc [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

a__f(b, X, c) → a__f(X, a__c, X) [1]
a__cb [1]
mark(f(X1, X2, X3)) → a__f(X1, mark(X2), X3) [1]
mark(c) → a__c [1]
mark(b) → b [1]
a__f(X1, X2, X3) → f(X1, X2, X3) [1]
a__cc [1]

The TRS has the following type information:
a__f :: b:c:f → b:c:f → b:c:f → b:c:f
b :: b:c:f
c :: b:c:f
a__c :: b:c:f
mark :: b:c:f → b:c:f
f :: b:c:f → b:c:f → b:c:f → b:c:f

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:
none

And the following fresh constants: none

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

a__f(b, X, c) → a__f(X, a__c, X) [1]
a__cb [1]
mark(f(X1, X2, X3)) → a__f(X1, mark(X2), X3) [1]
mark(c) → a__c [1]
mark(b) → b [1]
a__f(X1, X2, X3) → f(X1, X2, X3) [1]
a__cc [1]

The TRS has the following type information:
a__f :: b:c:f → b:c:f → b:c:f → b:c:f
b :: b:c:f
c :: b:c:f
a__c :: b:c:f
mark :: b:c:f → b:c:f
f :: b:c:f → b:c:f → b:c:f → b:c:f

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

b => 0
c => 1

(8) Obligation:

Complexity RNTS consisting of the following rules:

a__c -{ 1 }→ 1 :|:
a__c -{ 1 }→ 0 :|:
a__f(z, z', z'') -{ 1 }→ a__f(X, a__c, X) :|: z' = X, X >= 0, z = 0, z'' = 1
a__f(z, z', z'') -{ 1 }→ 1 + X1 + X2 + X3 :|: X1 >= 0, X3 >= 0, X2 >= 0, z = X1, z' = X2, z'' = X3
mark(z) -{ 1 }→ a__f(X1, mark(X2), X3) :|: X1 >= 0, X3 >= 0, z = 1 + X1 + X2 + X3, X2 >= 0
mark(z) -{ 1 }→ a__c :|: z = 1
mark(z) -{ 1 }→ 0 :|: z = 0

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1, V2),0,[fun(V, V1, V2, Out)],[V >= 0,V1 >= 0,V2 >= 0]).
eq(start(V, V1, V2),0,[fun1(Out)],[]).
eq(start(V, V1, V2),0,[mark(V, Out)],[V >= 0]).
eq(fun(V, V1, V2, Out),1,[fun1(Ret1),fun(X4, Ret1, X4, Ret)],[Out = Ret,V1 = X4,X4 >= 0,V = 0,V2 = 1]).
eq(fun1(Out),1,[],[Out = 0]).
eq(mark(V, Out),1,[mark(X21, Ret11),fun(X11, Ret11, X31, Ret2)],[Out = Ret2,X11 >= 0,X31 >= 0,V = 1 + X11 + X21 + X31,X21 >= 0]).
eq(mark(V, Out),1,[fun1(Ret3)],[Out = Ret3,V = 1]).
eq(mark(V, Out),1,[],[Out = 0,V = 0]).
eq(fun(V, V1, V2, Out),1,[],[Out = 1 + X12 + X22 + X32,X12 >= 0,X32 >= 0,X22 >= 0,V = X12,V1 = X22,V2 = X32]).
eq(fun1(Out),1,[],[Out = 1]).
input_output_vars(fun(V,V1,V2,Out),[V,V1,V2],[Out]).
input_output_vars(fun1(Out),[],[Out]).
input_output_vars(mark(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. non_recursive : [fun1/1]
1. recursive : [fun/4]
2. recursive [non_tail] : [mark/2]
3. non_recursive : [start/3]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into fun1/1
1. SCC is partially evaluated into fun/4
2. SCC is partially evaluated into mark/2
3. SCC is partially evaluated into start/3

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations fun1/1
* CE 8 is refined into CE [12]
* CE 7 is refined into CE [13]


### Cost equations --> "Loop" of fun1/1
* CEs [12] --> Loop 9
* CEs [13] --> Loop 10

### Ranking functions of CR fun1(Out)

#### Partial ranking functions of CR fun1(Out)


### Specialization of cost equations fun/4
* CE 6 is refined into CE [14]
* CE 5 is refined into CE [15,16]


### Cost equations --> "Loop" of fun/4
* CEs [16] --> Loop 11
* CEs [15] --> Loop 12
* CEs [14] --> Loop 13

### Ranking functions of CR fun(V,V1,V2,Out)

#### Partial ranking functions of CR fun(V,V1,V2,Out)


### Specialization of cost equations mark/2
* CE 10 is refined into CE [17,18]
* CE 11 is refined into CE [19]
* CE 9 is refined into CE [20,21,22]


### Cost equations --> "Loop" of mark/2
* CEs [22] --> Loop 14
* CEs [20] --> Loop 15
* CEs [21] --> Loop 16
* CEs [18] --> Loop 17
* CEs [17] --> Loop 18
* CEs [19] --> Loop 19

### Ranking functions of CR mark(V,Out)
* RF of phase [14,15,16]: [V]

#### Partial ranking functions of CR mark(V,Out)
* Partial RF of phase [14,15,16]:
- RF of loop [14:1]:
V
- RF of loop [15:1,16:1]:
V-1


### Specialization of cost equations start/3
* CE 2 is refined into CE [23,24,25]
* CE 3 is refined into CE [26,27]
* CE 4 is refined into CE [28,29,30]


### Cost equations --> "Loop" of start/3
* CEs [23,24,25,26,27,28,29,30] --> Loop 20

### Ranking functions of CR start(V,V1,V2)

#### Partial ranking functions of CR start(V,V1,V2)


Computing Bounds
=====================================

#### Cost of chains of fun1(Out):
* Chain [10]: 1
with precondition: [Out=0]

* Chain [9]: 1
with precondition: [Out=1]


#### Cost of chains of fun(V,V1,V2,Out):
* Chain [13]: 1
with precondition: [V+V1+V2+1=Out,V>=0,V1>=0,V2>=0]

* Chain [12,13]: 3
with precondition: [V=0,V2=1,Out=2*V1+1,Out>=1]

* Chain [11,13]: 3
with precondition: [V=0,V2=1,Out=2*V1+2,Out>=2]


#### Cost of chains of mark(V,Out):
* Chain [[14,15,16],19]: 10*it(14)+1
Such that:aux(3) =< V
it(14) =< aux(3)

with precondition: [V>=1,Out>=1,Out+1>=V]

* Chain [[14,15,16],18]: 10*it(14)+2
Such that:aux(4) =< V
it(14) =< aux(4)

with precondition: [V>=1,Out>=1,Out+2>=V]

* Chain [[14,15,16],17]: 10*it(14)+2
Such that:aux(5) =< V
it(14) =< aux(5)

with precondition: [V>=1,Out>=1]

* Chain [19]: 1
with precondition: [V=0,Out=0]

* Chain [18]: 2
with precondition: [V=1,Out=0]

* Chain [17]: 2
with precondition: [V=1,Out=1]


#### Cost of chains of start(V,V1,V2):
* Chain [20]: 30*s(8)+3
Such that:s(7) =< V
s(8) =< s(7)

with precondition: []


Closed-form bounds of start(V,V1,V2):
-------------------------------------
* Chain [20] with precondition: []
- Upper bound: nat(V)*30+3
- Complexity: n

### Maximum cost of start(V,V1,V2): nat(V)*30+3
Asymptotic class: n
* Total analysis performed in 143 ms.

(10) BOUNDS(1, n^1)